﻿using PureMVC.Interfaces;
using Rail.Commons;
using Rail.Start.Viewer;
using System.Collections.Generic;

namespace Rail.Start.Viewer
{
    public class SceneExtendMediator : PureMVC.Patterns.Mediator, IMediator
    {
        public new const string NAME = "SceneExtendMediator";
        SceneExtend m_SceneExtend;
        public SceneExtendMediator(SceneExtend viewComponent) : base(NAME, viewComponent)
        {
            this.m_SceneExtend = viewComponent;
        }
        /// <summary>
        /// 监听消息
        /// </summary>
        /// <returns></returns>
        public override IList<string> ListNotificationInterests()
        {
            IList<string> list = new List<string>();
            list.Add(Messages.SCENE_LOCATION);
            return list;
        }
        /// <summary>
        /// 处理消息
        /// </summary>
        /// <param name="note"></param>
        public override void HandleNotification(INotification note)
        {
            switch (note.Name)
            {
                ///定位消息
                case Messages.SCENE_LOCATION:
                    var body = note.Body as List<double>;
                    var lon = body[0];
                    var lat = body[1];
                    var alt = body[2];
                    this.m_SceneExtend.Scene.Fly(new SuperMap.Realspace.Camera(lon, lat, alt));
                    break;
            }
        }
    }
}
